﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using BuildARoute.Views;

namespace BuildARoute.Controls
{
    public partial class TourControl : UserControl
    {
        public TourControl()
        {
            InitializeComponent();

            this.editButton.SetBinding(Button.IsEnabledProperty, new Binding("User.IsAuthenticated") { Source = App.Current.Resources["WebContext"] });
            this.editButton.SetBinding(Button.VisibilityProperty, new Binding("DataContext") { Source = this, Converter = new VisibleWhenBoundConverter() });
            this.viewStopsButton.SetBinding(Button.VisibilityProperty, new Binding("DataContext") { Source = this, Converter = new VisibleWhenBoundConverter() });
            if (DesignerProperties.IsInDesignTool)
            {
                this.titleTextBlock.Text = "Design Tour";
                this.shortDescriptionTextBlock.Text = "consectetuer adipiscing elit. Proin turpis. Etiam  ultrices vitae, fringilla sollicitudin, sagittis a, ante. Quisque";

                this.longDescriptionTextBlock.Text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin turpis. Etiam ante tortor, ultrices vitae, fringilla sollicitudin, sagittis a, ante. Quisque luctus, magna vitae elementum mattis, dui massa ultricies ligula, eget posuere orci est vitae neque. Nam interdum molestie tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin euismod euismod nunc. Praesent pretium sem in dolor. Maecenas velit ante, varius eu, volutpat ut, consequat ut, orci. Cras laoreet. Sed turpis. Mauris laoreet orci non diam.  Pellentesque consectetuer imperdiet neque. Aliquam sed nibh eget libero sodales imperdiet. Proin placerat faucibus enim. Nullam ante. Praesent venenatis. ";
                this.createdTextBlock.Text = DateTime.Now.ToShortDateString();
                this.durationTextBlock.Text = "50 mins";
            }
        }

        private void editButton_Click(object sender, RoutedEventArgs e)
        {
            var editTour = new CreateTourWindow();
            editTour.DataContext = this.DataContext;
            editTour.Show();
        }
    }
}
